package io.gitee.yxsnake.embark.web.core.context;

import java.util.Objects;

/**
 * @author snake
 * @description 链路上下文
 * @since 2024/9/28 23:48
 */

public class TrackContext {

    private final static ThreadLocal<String> CONTEXT = new ThreadLocal<>();

    private TrackContext() {
    }

    public static void setTrackId(String trackId) {
        CONTEXT.set(trackId);
    }

    public static String getTrackId() {
        return Objects.isNull(CONTEXT.get()) ? "" : CONTEXT.get();
    }

    public static void remove() {
        CONTEXT.remove();
    }
}
